/******************************************************************************
 * @File name   :      EligibilityDaoImpl.java
 *
 * @Author      :      GUDONG
 *
 * @Date        :      2015年10月23日
 *
 * @Copyright Notice: 
 * Copyright (c) 2014 Capgemini, Inc. All  Rights Reserved.
 * This software is published under the terms of the Capgemini Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * 2015年10月23日 下午3:49:36        GUDONG     1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.crmdp.dealer.coupon.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.crmdp.dealer.coupon.dao.IEligibilityLineDao;
import com.cap.bts.crmdp.dealer.coupon.domain.EligibilityLine;
import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;
import com.cap.bts.framework.common.exception.AppException;

/**
 *
 */
@Repository
public class EligibilityLineDaoImpl extends BaseDaoImpl<EligibilityLine, Long> implements IEligibilityLineDao  {

    /**
     * @Date        :      2015年11月15日
     * @param clazz
     */
    @Inject
    public EligibilityLineDaoImpl(@Value("com.cap.bts.crmdp.dealer.coupon.domain.EligibilityLine") Class<EligibilityLine> clazz) {
        super(clazz);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年11月15日
     * @see com.cap.bts.crmdp.dealer.coupon.dao.IEligibilityLineDao#getEligibilityLineByTicketLineId(java.lang.Long)
    **/
    @Override
    public List<EligibilityLine> getEligibilityLineByEligibilityId(Long id) throws AppException {
        String sql = "select * from tm_item_eligibility_def_line a where a.eligibility_id =" + id;
        return this.getListByNativeQuery(sql);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年11月15日
     * @see com.cap.bts.crmdp.dealer.coupon.dao.IEligibilityLineDao#getEligibilityLineById(java.lang.Long)
    **/
    @Override
    public List<EligibilityLine> getEligibilityLineById(Long id) throws AppException {
        String sql = "select * from tm_item_eligibility_def_line a where a.id =" + id;
        return this.getListByNativeQuery(sql);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年11月17日
     * @see com.cap.bts.crmdp.dealer.coupon.dao.IEligibilityLineDao#removeRowByEligibilityId(java.lang.Long)
    **/
    @Override
    public void removeRowByEligibilityId(Long eligibilityId) throws AppException {
        String sql = "delete from tm_item_eligibility_def_line"
            + " where eligibility_id =" + eligibilityId;
        this.getEntityManager().createNativeQuery(sql).executeUpdate();
    }

}
